package com.iap.common.translator
{
	import com.iap.app.translator.Translator;
	import com.iap.common.model.ClientInstance;
	
	import flash.utils.getQualifiedClassName;
	
	public class ClientInstanceTranslator extends Translator
	{
		public static function translate(item:Object):Object
		{
			if(getQualifiedClassName(item) == "Array")
			{
				return translateFromArray(item as Array);
			} else {
				return translateItem(item);
			}
		}
		
		public static function translateFromArray(data:Array):Array
		{
			var list:Array = new Array();
			for each(var item:Object in data)
			{
				list.push(translateItem(item));
			}
			return list;
		}
		
		private static function translateItem(item:Object):ClientInstance
		{
			var result:ClientInstance = translateFromObject(item, getQualifiedClassName(ClientInstance)) as ClientInstance;
			return result;
		}
	}
}